﻿using System.Web.Mvc;
using System.Web.Routing;
using Nop.Web.Framework.Localization;
using Nop.Web.Framework.Mvc.Routes;

namespace Logistics.Web.Infrastructure
{
    public class RouteProvider : IRouteProvider
    {
        public void RegisterRoutes(RouteCollection routes)
        {
            routes.MapRoute("InvoiceDownload",
                  "invoice/{number}/{guid}",
                  new { area = "Logistics", controller = "Order", action = "DownloadInvoice" },
                  new { number = @"[A-Za-z]+\d+", guid = @"\b\w{8}(?:-\w{4}){3}-\w{12}\b" },
                  new[] { "Logistics.Web.Controllers" });

            routes.MapLocalizedRoute("LogisticsTrack",
                              "express/track/status/{pid}",
                              new { area = "Logistics", controller = "Track", action = "Status", pid = UrlParameter.Optional },
                              new[] { "Logistics.Web.Controllers" });

            routes.MapLocalizedRoute("LogisticsRoutePlan",
                              "express/track/plannedroutelist/{id}",
                              new { area = "Logistics", controller = "Track", action = "PlannedRouteList", id = UrlParameter.Optional },
                              new[] { "Logistics.Web.Controllers" });


            routes.MapLocalizedRoute("LogisticsMyHub",
                              "express/order",
                              new { area = "Logistics", controller = "Order", action = "Index" },
                              new[] { "Logistics.Web.Controllers" });

            routes.MapLocalizedRoute("LogisticsOrder",
                              "express/order/placeorder",
                              new { area = "Logistics", controller = "Order", action = "PlaceOrder" },
                              new[] { "Logistics.Web.Controllers" });

            routes.MapLocalizedRoute("LogisticsOrderCancel",
                             "express/order/ordercancel",
                             new { area = "Logistics", controller = "Order", action = "OrderCancel" },
                             new[] { "Logistics.Web.Controllers" });

            routes.MapLocalizedRoute("LogisticsOrderAddress",
                            "express/order/ordercancel",
                            new { area = "Logistics", controller = "Order", action = "OrderCancel" },
                            new[] { "Logistics.Web.Controllers" });

            routes.MapLocalizedRoute("LogisticsOrderAddressList",
                            "express/order/GetAddressList",
                            new { area = "Logistics", controller = "Order", action = "GetAddressList" },
                            new[] { "Logistics.Web.Controllers" });
            // Order Routes
            routes.MapLocalizedRoute("LogisticsCreateOrder",
                              "express/order/createorder",
                              new { area = "Logistics", controller = "Order", action = "OrderInfo" },
                              new[] { "Logistics.Web.Controllers" });
            routes.MapLocalizedRoute("LogisticsOrderLocation",
                              "express/order/location",
                              new { area = "Logistics", controller = "Order", action = "Location" },
                              new[] { "Logistics.Web.Controllers" });
            routes.MapLocalizedRoute("LogisticsOrderPackage",
                              "express/order/package",
                              new { area = "Logistics", controller = "Order", action = "Package" },
                              new[] { "Logistics.Web.Controllers" });
            routes.MapLocalizedRoute("LogisticsOrderDetail",
                              "express/order/detail",
                              new { area = "Logistics", controller = "Order", action = "Detail" },
                              new[] { "Logistics.Web.Controllers" });
            routes.MapLocalizedRoute("LogisticsSummary",
                              "express/order/summary",
                              new { area = "Logistics", controller = "Order", action = "Summary" },
                              new[] { "Logistics.Web.Controllers" });
            routes.MapLocalizedRoute("LogisticsCostCalculate",
                              "express/order/ajaxcostcalculate",
                              new { area = "Logistics", controller = "Order", action = "AjaxCostCalculate" },
                              new[] { "Logistics.Web.Controllers" });
            routes.MapLocalizedRoute("LogisticsBillingInfo",
                              "express/order/billinginfo",
                              new { area = "Logistics", controller = "Order", action = "BillingInfo" },
                              new[] { "Logistics.Web.Controllers" });
            routes.MapRoute("AjaxCalculatePackageCost",
                              "express/rate/ajaxcalculatepackagecost",
                              new { area = "Logistics", controller = "Rate", action = "AjaxCalculatePackageCost" },
                              new[] { "Logistics.Web.Controllers" });

            routes.MapRoute("PackageComment",
                              "shipment/packagecomment",
                              new { area = "Logistics", controller = "Shipment", action = "PackageComment" },
                              new[] { "Logistics.Web.Controllers" });
            //routes.MapRoute("LogisticsShipmentDetail",
            //                  "express/shipment/Details",
            //                  new { area = "Logistics", controller = "Shipment", action = "Detail" },
            //                  new[] { "Logistics.Web.Controllers" });
            routes.MapRoute("LogisticsTrackDetail",
                  "express/Track/PackageTracking",
                  new { area = "Logistics", controller = "Track", action = "PackageTracking" },
                  new[] { "Logistics.Web.Controllers" });

            routes.MapRoute("Shipment",
                              "shipment/{shipmentId}",
                              new { area = "Logistics", controller = "Shipment", action = "Details" },
                              new { shipmentId = @"\d+" },
                              new[] { "Logistics.Web.Controllers" });

            routes.MapRoute("ShipmentChangeAddress",
                              "shipment/changeaddress/{packageId}-{typeId}",
                              new { area = "Logistics", controller = "Shipment", action = "ChangeAddress" },
                              new { packageId = @"\d+", typeId = @"\d+" },
                              new[] { "Logistics.Web.Controllers" });
            routes.MapRoute("ShipmentPaymentInfo",
                              "shipment/paymentinfo",
                              new { area = "Logistics", controller = "Shipment", action = "PaymentInfo" },
                              new[] { "Logistics.Web.Controllers" });
            routes.MapRoute("ShipmentScheduleDelivery",
                             "shipment/ScheduleDelivery/{packageId}",
                             new { area = "Logistics", controller = "Shipment", action = "ScheduleDelivery" },
                             new { packageId = @"\d+"},
                             new[] { "Logistics.Web.Controllers" });
        }

        public int Priority
        {
            get { return 0; }
        }
    }
}